<?php
echo $this->Html->css('datepicker/stylesheets/gui');
echo $this->Html->css('datepicker/stylesheets/timeframe');
?>
  <!--[if lt IE 8]>
    <style type="text/css" media="screen">
      div.timeframe_calendar li a, div.timeframe_calendar table {
        display: inline;
      }
    </style>
  <![endif]-->
  <!--[if lt IE 7]>
    <link rel="stylesheet" href="stylesheets/ie6.css" type="text/css" media="screen" title="ie6" charset="utf-8"/>
<?php
echo $this->Html->css('datepicker/stylesheets/ie6');
?>
<![endif]-->
<div class="breadcrumb">
    <ul id="breadcrumb">
        <li><a href="<?php echo Configure::read('base_url');?>backstage" title="Home">
		<?php echo $this->Html->image("home.png", array("alt" => "Home",'class'=>'home','border'=>'0'));?>
		</a></li>
               <li>Sales Review</li>
    </ul>
</div>
<?php echo $this->element('admin/admin_leftmenu'); ?>
<div id="left">
    <?php
    echo $this->Session->flash();
    if ($this->Session->check('Message.auth'))
        echo $this->Session->flash('auth');
    ?>
    <div class="div_header"><?php __('Sales Review'); ?></div>
    <div class="div_content">
        <div class="paging">
          <button>Date Range</button>
     <div id="example" style="display: none;">
      <h4>Please select a date range below:</h4>
      <div id="calendars"></div>
      <div id="calendar_form">
        <div id="labels">
          <label for="start">Date Range</label><label for="end"></label> (<a href="#" onclick="return false;" id="reset">reset</a>):
        </div>
          <form accept-charset="utf-8" action="<?php echo Configure::read('base_url');?>backstage/products/salesreview" method="post" id="productmessage">
        <div id="fields">
          <span>
            <input type="text" name="start" class="required" value="" id="start"/>
            &ndash;
            <input class="required" type="text" name="end" value="" id="end"/>
          </span>
        </div>

          <div style="padding-top:5px;">
              <input type="submit" style="background:#73AE0B; color:#fff; font-size:14px;" name="button" id="button" value="Submit" />
          </div>
              </form>
      </div>
    </div>
    <?php  //echo $html->script(array("jquery.min.js","prototype.js","timeframe.js")); ?>
    <script type="text/javascript" charset="utf-8">
    //<![CDATA[
      new Timeframe('calendars', {
          months:3,
        startField: 'start',
        endField: 'end',
        earliest: new Date("October 13, 1975"),
        resetButton: 'reset' });
    //]]>
  </script>
          <script>
    jQuery("button").click(function () {
      jQuery("#example").slideToggle("slow");
    });
</script>
  <script type="text/javascript">
 jQuery(document).ready(function(){
		var v = jQuery("#productmessage").validate({
                    rules: {
                    }
	});
                });
 </script>
	</div>
      <table id="category_table" cellspacing="0" class="tablesorter">
            <thead>
               <tr style="background:gray;">
			<th>ID</th>
			<th>Seller Name</th>
			<th>Buyer Name</th>
			<th>Product Title</th>
                        <th>Order Date</th>
			<th>Sale Amount</th>
                </tr>
            </thead>
            <tbody>
                <?php
               $i = 0;
               //pr($products);
               if(!empty($reports)){
                foreach ($reports as $product):
                    $class = null;
                    if ($i++ % 2 == 0) 
                    $class = ' class="alt"';
                    
                ?>
                                  
                    <tr class="fullrow<?php echo $product['Product']['id']; ?>">
                    <td <?php echo $class;?>  style="vertical-align: middle;">
                     <?php echo $product['Order']['id']; ?>
                    </td>
                    <td <?php echo $class;?>  style="vertical-align: middle;">
                     <?php echo $product['Seller']['username']; ?>
                    </td>
                    <td <?php echo $class;?>  style="vertical-align: middle;">
                     <?php echo $product['User']['username']; ?>
                    </td>
                    <td  <?php echo $class;?>  style="vertical-align: middle;">
                    <?php echo $product['Product']['products_title']; ?>
                    </td>
                    <td <?php echo $class;?>  style="vertical-align: middle;">
                    <?php echo date('d/m/Y',  strtotime($product['Order']['add_date'])); ?>
                    </td>
                    <td <?php echo $class;?>  style="vertical-align: middle;">
                    <?php echo $product['Order']['quantity']*$product['Order']['product_cost']; ?>
                    </td>
                  </tr>
        <?php
        endforeach;
               }else{
                   ?>
                   <tr>
         <td colspan="6">
             No Data Found.
             </td></tr>
                  <?php

               }
        ?>
           <tbody>
         </table>
        <?php
         if(!empty($reports)){
        ?>
        <table id="category_table" cellspacing="0" class="tablesorter">
            <thead>
               <tr style="background:gray;">
                	<th>Total Products: <?php
                        echo $totalproduct[0][0]['tquantity'];
                        ?></th>
			<th>Total Sellers: <?php
                        echo $totalseller[0][0]['totalseller'];
                        ?></th>
			<th>Total Buyers: <?php
                        echo $totalbuyers[0][0]['totalbuyer'];
                        ?></th>
                        <th>Total Amount: <?php
                        echo $totalsales[0][0]['totalsale'];
                        ?></th>
			<th>
                            <a href="<?php echo Configure::read('base_url');?>/products/generatereport/<?php echo strtotime($startdate)."/".strtotime($enddate);?>">
                        Click here to generate report
                        </a>
                        </th>
	</tr>
            </thead>
            <tbody>
            <tbody>
         </table>
        <?php
        
        }
        ?>
        <div class="paging">
		
	</div>
            </div>
            <div class="div_bottom"></div>
        </div>

        <!-- edit sidebar items here -->

        </div>
<?php
echo $this->Html->css('table_css');
?>